﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TriggerCollision : TriggerBase
{
    //public string targetName = "Unit";
    public LayerMask triggerLayer;


    public override void InitTrigger()
    {
        base.InitTrigger();
    }

    void OnTriggerEnter2D(Collider2D collider2d)
    {

        Debug.LogError("collider2d " + collider2d.gameObject.name);
        if(Util.IsInLayerMask(collider2d.gameObject.layer,triggerLayer))
        {
            OnTrigger();
        }
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.LogError("Collision2D " + collision.gameObject.name);
        if (Util.IsInLayerMask(collision.gameObject.layer, triggerLayer))
        {
            OnTrigger();
        }
    }
}
